#pragma once
#include<iostream>
#include<string>





#define Die(code) do{exit(code);}while(0)
#define CONV(v) (struct sockaddr*)(v)


enum{
    USAGE_ERR = 1,
    SOCKET_ERR,
    BIND_ERR
};


/*bool SplitString(const std::string& line,std::string* key,std::string* value,const std::string& sep)//分隔符sep
{
    auto pos = line.find(sep);
    if(pos == std::string::npos) return false;

    *key = line.substr(0,pos);//左闭右开，pos在:处的位置
    *value = line.substr(pos+2); 

    if(key->empty()||value->empty())return false;

    return true;
}*/

bool SplitString(const std::string& line,std::string* key,std::string* value,const std::string& sep)//分隔符sep
{

    auto pos = line.find(sep);//pos是:
    *key = line.substr(0,pos);
    *value = line.substr(pos+2);

    if((key->empty()||value->empty())||(key->empty()&&value->empty()))return false;
    
    return true;
}